package io;

import java.io.*;

/**
 * @author Luka
 * @date 2021/05/28 16:35
 *
 * 适用对象输入流玩成对象的反序列化
 **/
public class OISDemo {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        //从person.obj文件中将对象反序列化回来
        FileInputStream fis = new FileInputStream("person.obj");
        ObjectInputStream ois = new ObjectInputStream(fis);

        /*
            Object readObject()
            该方法进行对象反序列化,如果对象流通过对其连接的流读取的字节分析并非
            是一个java对象时,会抛出异常:ClassNotFoundException
         */
        Person p =(Person)ois.readObject() ;
        System.out.println(p);


    }

}